/************************************************************
  *  * EaseMob CONFIDENTIAL 
  * __________________ 
  * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved. 
  *  
  * NOTICE: All information contained herein is, and remains 
  * the property of EaseMob Technologies.
  * Dissemination of this information or reproduction of this material 
  * is strictly forbidden unless prior written permission is obtained
  * from EaseMob Technologies.
  */

#import "BaseTableViewCell.h"

@implementation BaseTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.warmNumber=@"0";
        _bottomLineView = [[UIView alloc] init];
    
        _bottomLineView.backgroundColor = [UIColor colorWithRed:207 / 255.0 green:210 /255.0 blue:213 / 255.0 alpha:0.7];
        [self.contentView addSubview:_bottomLineView];
        
        self.textLabel.backgroundColor = [UIColor clearColor];
        
        _headerLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(headerLongPress:)];
        [self addGestureRecognizer:_headerLongPress];
        
        
        
         self.warmView =[[UIView alloc] init];
        [self.warmView  setBackgroundColor:[UIColor redColor]];
          self.warmView .layer.cornerRadius =9;//设置那个圆角的有多圆
          self.warmView .layer.borderWidth = 0;//设置边框的宽度，当然可以不要
          self.warmView .layer.borderColor = [[UIColor redColor] CGColor];//设置边框的颜色
          self.warmView .layer.masksToBounds = YES;
        [self.contentView  addSubview:  self.warmView ];
        
        self.warmtext=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
        self.warmtext.textAlignment=NSTextAlignmentCenter;
        self.warmtext.font=systemFont(15);
        self.warmtext.autoresizingMask=UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
        self.warmtext.textColor=[UIColor whiteColor];
        [self.warmView addSubview:  self.warmtext];
    }
    return self;
}

- (void)awakeFromNib
{
    // Initialization code
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.frame = CGRectMake(10, 8, 34, 34);
    
    CGRect rect = self.textLabel.frame;
    rect.origin.x = CGRectGetMaxX(self.imageView.frame) + 10;
    self.textLabel.frame = rect;
    
    
    rect = self.detailTextLabel.frame;
    self.detailTextLabel.textColor=[UIColor lightGrayColor];
    rect.origin.x = CGRectGetMaxX(self.imageView.frame) + 10;
    self.detailTextLabel.frame = rect;
    
    _bottomLineView.frame = CGRectMake(0, self.contentView.frame.size.height - 1, self.contentView.frame.size.width, 1);
    self.warmView.frame = CGRectMake(44-9,2,18,18);
    self.warmtext.text=self.warmNumber;
    [self.contentView bringSubviewToFront: self.warmView];
    
    if([self.warmNumber isEqualToString:@"0"])
    {
        self.warmView.hidden=YES;
    }
    else
    {
        self.warmView.hidden=NO;

    }

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)headerLongPress:(UILongPressGestureRecognizer *)longPress
{
    if (longPress.state == UIGestureRecognizerStateBegan) {
        if(_delegate && _indexPath && [_delegate respondsToSelector:@selector(cellImageViewLongPressAtIndexPath:)])
        {
            [_delegate cellImageViewLongPressAtIndexPath:self.indexPath];
        }
    }
}

@end
